Repository navigation
refactor: build editor image lists with one library scanner - #341
Conversation
Add wm_editor_attributes() and wm_editor_option() so every attribute value and option label on the editor page is escaped by construction. Attribute names must match a plain HTML name; true renders a boolean attribute and false or null omits it. Values use plugin_weathermap_escape_attr(), which double-encodes, so names such as "A&B.png" round-trip instead of collapsing to "A&B.png". Convert the icon, background, graph template, background sizing and key style lists, and get_fontlist(). The key style labels were previously printed unescaped, and the "Special Icon (AICON)" placeholder lost a stray ">". Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…ge lists Fail when the editor page concatenates or interpolates an unescaped value into an HTML attribute, or prints an <option> without wm_editor_option(). Render the icon and background lists from real image files with hostile names through the editor page's own code, parse the result with DOMDocument, and check that no attributes or elements are injected and that every value and label round-trips. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
get_imagelist() and wm_asset_image_list() each scanned images/objects
and images/backgrounds with slightly different rules. Both now use
wm_asset_library_images(), which returns {kind, name, url, path} entries
under one set of acceptance rules: a readable regular file named
.png/.gif/.jpg/.jpeg whose content is a PNG, JPEG or GIF raster.
Symlinked files and libraries stay selectable in the editor but are
flagged unmanaged, so the image library dialog still refuses to list,
delete or overwrite them, as before.
The editor page builds its selectors with wm_editor_image_options() and
renders each entry through wm_editor_image_option(), a thin wrapper over
wm_editor_option(), so data-imagesrc carries the same encoded images/ URL
the library dialog sends to wmEditorImageSrc(). The hostile-filename E2E
test now expects that encoded URL and the entry list shape. Map images
outside the library keep their value; only images/ paths get a preview.
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The PHP E2E test renders the icon and background selectors from a temporary images tree through the editor's own helpers and compares the result with a committed fixture. The browser test loads that fixture into jsdom and checks every preview URL through the real wmEditorImageSrc() and wmNodeIconPicker(). Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The option lists now pass __() text to the escaping helper instead of __esc(), so the template's source references change. Regenerating also adds strings the template was already missing. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Write each extracted section to a temporary file and include it in the caller's scope, as the page runs it, instead of passing it to eval(). Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
… into refactor/editor-image-list Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> # Conflicts: # tests/E2E/EditorImageOptionListsTest.php
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Tested I reproduced the interaction you mentioned with #347: once both are merged, EditorImageOptionsTest.cjs fails with Worth making that adjustment in whichever PR merges second. The image-picker changes can share a focused real-browser check with #347 once combined. |
Slicing wmEditorImageSrc() out of editor.js breaks once the editor script is split into separate files. Evaluating every editor script the page includes keeps the check independent of which file declares it. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
EditorImageOptionsTest now evaluates every editor script the page includes instead of slicing I also did the real-browser check in Safari 27.2 against Cacti 1.2.32 with #336, #341, #347 and #333 combined: all 97 icon previews load, search filters the list, choosing an icon sets the field, closes the picker and returns focus to it, and Escape closes the picker without closing the node dialog. No JavaScript errors. |
…age-list Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|



Fixes #340
Stacked on #336, so merge #336 first. This PR targets #336's branch until then.
One scanner,
wm_asset_library_images(), now builds the editor image lists. It returns entries shaped {kind, name, url, path}, under one set of rules: a readable regular file, with a png/gif/jpe?g extension and PNG/JPEG/GIF content.get_imagelist(),wm_asset_image_list()and the editor selectors all use it.images/URL as the library dialog indata-imagesrc, so the server andwmEditorImageSrc()share one contract. Option values and their order are unchanged, and map images outside the library keep their value.0no longer ends the scan early. Backgrounds now list in filename order instead of directory order.wmEditorImageSrc()andwmNodeIconPicker().Interaction: #347 splits js/editor.js, and EditorImageOptionsTest.cjs here slices editor.js for
wmEditorImageSrc(). Whichever of the two merges second needs that test switched to the shared loader.